{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Imports for data io operations\n",
    "from collections import deque\n",
    "from six import next\n",
    "import readers\n",
    "\n",
    "# Main imports for training\n",
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "\n",
    "# Evaluate train times per epoch\n",
    "import time\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>item</th>\n",
       "      <th>rate</th>\n",
       "      <th>st</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1192</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978300760</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>660</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978302109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>913</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978301968</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>3407</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978300275</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>2354</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978824291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>1196</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978302268</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0</td>\n",
       "      <td>1286</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978302039</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0</td>\n",
       "      <td>2803</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978300719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0</td>\n",
       "      <td>593</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978302268</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0</td>\n",
       "      <td>918</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978301368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0</td>\n",
       "      <td>594</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978824268</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0</td>\n",
       "      <td>937</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978301752</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0</td>\n",
       "      <td>2397</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978302281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0</td>\n",
       "      <td>2917</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978302124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0</td>\n",
       "      <td>1034</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978301753</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0</td>\n",
       "      <td>2790</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978302188</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0</td>\n",
       "      <td>2686</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978824268</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0</td>\n",
       "      <td>2017</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978301777</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0</td>\n",
       "      <td>3104</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978301713</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0</td>\n",
       "      <td>2796</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978302039</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>0</td>\n",
       "      <td>2320</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978302205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0</td>\n",
       "      <td>719</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978300760</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>0</td>\n",
       "      <td>1269</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978300055</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>0</td>\n",
       "      <td>526</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978824195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>0</td>\n",
       "      <td>2339</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978300103</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>0</td>\n",
       "      <td>47</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978824351</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>0</td>\n",
       "      <td>1096</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978301953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>0</td>\n",
       "      <td>1720</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978300055</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>0</td>\n",
       "      <td>1544</td>\n",
       "      <td>4.0</td>\n",
       "      <td>978824139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>0</td>\n",
       "      <td>744</td>\n",
       "      <td>3.0</td>\n",
       "      <td>978824268</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000179</th>\n",
       "      <td>6039</td>\n",
       "      <td>2761</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956704584</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000180</th>\n",
       "      <td>6039</td>\n",
       "      <td>1035</td>\n",
       "      <td>3.0</td>\n",
       "      <td>956715455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000181</th>\n",
       "      <td>6039</td>\n",
       "      <td>507</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956704972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000182</th>\n",
       "      <td>6039</td>\n",
       "      <td>1040</td>\n",
       "      <td>4.0</td>\n",
       "      <td>957717678</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000183</th>\n",
       "      <td>6039</td>\n",
       "      <td>3734</td>\n",
       "      <td>4.0</td>\n",
       "      <td>960971654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000184</th>\n",
       "      <td>6039</td>\n",
       "      <td>2790</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956715569</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000185</th>\n",
       "      <td>6039</td>\n",
       "      <td>2793</td>\n",
       "      <td>1.0</td>\n",
       "      <td>956716438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000186</th>\n",
       "      <td>6039</td>\n",
       "      <td>526</td>\n",
       "      <td>5.0</td>\n",
       "      <td>956704219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000187</th>\n",
       "      <td>6039</td>\n",
       "      <td>2002</td>\n",
       "      <td>1.0</td>\n",
       "      <td>956716294</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000188</th>\n",
       "      <td>6039</td>\n",
       "      <td>534</td>\n",
       "      <td>4.0</td>\n",
       "      <td>964828734</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000189</th>\n",
       "      <td>6039</td>\n",
       "      <td>2009</td>\n",
       "      <td>5.0</td>\n",
       "      <td>957716795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000190</th>\n",
       "      <td>6039</td>\n",
       "      <td>2010</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956716113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000191</th>\n",
       "      <td>6039</td>\n",
       "      <td>3750</td>\n",
       "      <td>4.0</td>\n",
       "      <td>964828782</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000192</th>\n",
       "      <td>6039</td>\n",
       "      <td>2018</td>\n",
       "      <td>5.0</td>\n",
       "      <td>956703977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000193</th>\n",
       "      <td>6039</td>\n",
       "      <td>540</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956715288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000194</th>\n",
       "      <td>6039</td>\n",
       "      <td>1076</td>\n",
       "      <td>5.0</td>\n",
       "      <td>964828799</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000195</th>\n",
       "      <td>6039</td>\n",
       "      <td>1078</td>\n",
       "      <td>2.0</td>\n",
       "      <td>956715648</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000196</th>\n",
       "      <td>6039</td>\n",
       "      <td>548</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956704746</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000197</th>\n",
       "      <td>6039</td>\n",
       "      <td>2019</td>\n",
       "      <td>3.0</td>\n",
       "      <td>956715288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000198</th>\n",
       "      <td>6039</td>\n",
       "      <td>2020</td>\n",
       "      <td>3.0</td>\n",
       "      <td>956716374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000199</th>\n",
       "      <td>6039</td>\n",
       "      <td>2021</td>\n",
       "      <td>5.0</td>\n",
       "      <td>956716207</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000200</th>\n",
       "      <td>6039</td>\n",
       "      <td>2027</td>\n",
       "      <td>5.0</td>\n",
       "      <td>956704519</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000201</th>\n",
       "      <td>6039</td>\n",
       "      <td>1079</td>\n",
       "      <td>4.0</td>\n",
       "      <td>957717322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000202</th>\n",
       "      <td>6039</td>\n",
       "      <td>1088</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956704996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000203</th>\n",
       "      <td>6039</td>\n",
       "      <td>1089</td>\n",
       "      <td>3.0</td>\n",
       "      <td>956715518</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000204</th>\n",
       "      <td>6039</td>\n",
       "      <td>1090</td>\n",
       "      <td>1.0</td>\n",
       "      <td>956716541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000205</th>\n",
       "      <td>6039</td>\n",
       "      <td>1093</td>\n",
       "      <td>5.0</td>\n",
       "      <td>956704887</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000206</th>\n",
       "      <td>6039</td>\n",
       "      <td>561</td>\n",
       "      <td>5.0</td>\n",
       "      <td>956704746</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000207</th>\n",
       "      <td>6039</td>\n",
       "      <td>1095</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956715648</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000208</th>\n",
       "      <td>6039</td>\n",
       "      <td>1096</td>\n",
       "      <td>4.0</td>\n",
       "      <td>956715569</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000209 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         user  item  rate         st\n",
       "0           0  1192   5.0  978300760\n",
       "1           0   660   3.0  978302109\n",
       "2           0   913   3.0  978301968\n",
       "3           0  3407   4.0  978300275\n",
       "4           0  2354   5.0  978824291\n",
       "5           0  1196   3.0  978302268\n",
       "6           0  1286   5.0  978302039\n",
       "7           0  2803   5.0  978300719\n",
       "8           0   593   4.0  978302268\n",
       "9           0   918   4.0  978301368\n",
       "10          0   594   5.0  978824268\n",
       "11          0   937   4.0  978301752\n",
       "12          0  2397   4.0  978302281\n",
       "13          0  2917   4.0  978302124\n",
       "14          0  1034   5.0  978301753\n",
       "15          0  2790   4.0  978302188\n",
       "16          0  2686   3.0  978824268\n",
       "17          0  2017   4.0  978301777\n",
       "18          0  3104   5.0  978301713\n",
       "19          0  2796   4.0  978302039\n",
       "20          0  2320   3.0  978302205\n",
       "21          0   719   3.0  978300760\n",
       "22          0  1269   5.0  978300055\n",
       "23          0   526   5.0  978824195\n",
       "24          0  2339   3.0  978300103\n",
       "25          0    47   5.0  978824351\n",
       "26          0  1096   4.0  978301953\n",
       "27          0  1720   4.0  978300055\n",
       "28          0  1544   4.0  978824139\n",
       "29          0   744   3.0  978824268\n",
       "...       ...   ...   ...        ...\n",
       "1000179  6039  2761   4.0  956704584\n",
       "1000180  6039  1035   3.0  956715455\n",
       "1000181  6039   507   4.0  956704972\n",
       "1000182  6039  1040   4.0  957717678\n",
       "1000183  6039  3734   4.0  960971654\n",
       "1000184  6039  2790   4.0  956715569\n",
       "1000185  6039  2793   1.0  956716438\n",
       "1000186  6039   526   5.0  956704219\n",
       "1000187  6039  2002   1.0  956716294\n",
       "1000188  6039   534   4.0  964828734\n",
       "1000189  6039  2009   5.0  957716795\n",
       "1000190  6039  2010   4.0  956716113\n",
       "1000191  6039  3750   4.0  964828782\n",
       "1000192  6039  2018   5.0  956703977\n",
       "1000193  6039   540   4.0  956715288\n",
       "1000194  6039  1076   5.0  964828799\n",
       "1000195  6039  1078   2.0  956715648\n",
       "1000196  6039   548   4.0  956704746\n",
       "1000197  6039  2019   3.0  956715288\n",
       "1000198  6039  2020   3.0  956716374\n",
       "1000199  6039  2021   5.0  956716207\n",
       "1000200  6039  2027   5.0  956704519\n",
       "1000201  6039  1079   4.0  957717322\n",
       "1000202  6039  1088   4.0  956704996\n",
       "1000203  6039  1089   3.0  956715518\n",
       "1000204  6039  1090   1.0  956716541\n",
       "1000205  6039  1093   5.0  956704887\n",
       "1000206  6039   561   5.0  956704746\n",
       "1000207  6039  1095   4.0  956715648\n",
       "1000208  6039  1096   4.0  956715569\n",
       "\n",
       "[1000209 rows x 4 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "df = readers.read_file(\"./ml-1m/ratings.dat\", sep=\"::\")\n",
    "rows = len(df)\n",
    "df\n",
    "# Purely integer-location based indexing for selection by position\n",
    "#df = df.iloc[np.random.permutation(rows)].reset_index(drop=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
